'''
The module is responsible to manage the overridden entities.

@author: Oraby
'''

#TODO: Move the methods out of the class and make them public functions

class OverrideManager(object):
    '''
    A static class that maintains the overridden entities.
    '''

    _originalFn = {}
    
    
    def storeEntity(originalFn, fullName):
        '''
        Store method, class, Module.
        
        @type originalFn: C{callable}, C{class}, C{Python Module}
        @param originalFn: The original function that will be 
            stored.
            
        @type fullName: C{str}
        @param fullName: The entity full name including it's 
            preceding package name.
        '''
        OverrideManager._originalFn[fullName] = originalFn
        #originalFn = newFn #We need pass by reference to  be able to do that
    storeEntity = staticmethod(storeEntity)
    
    def getEntity(fullName):
        '''
        Return a stored entity.
        
        @type fullName: C{str} or C{None}
        @param fullName: The full name of the entity being looked
            up. If the name wasn't found then C{None} is returned.
        '''
        try:
            return OverrideManager._originalFn[fullName]
        except Exception:
            return None
    getEntity = staticmethod(getEntity)